package com.mku.wms_service.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mku.wms_service.common.QueryPageParam;
import com.mku.wms_service.common.Response;
import com.mku.wms_service.entity.Goods;
import com.mku.wms_service.service.IGoodsService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author maoxx
 * @since 2024-11-22
 */
@RestController
@RequestMapping("/goods")
public class GoodsController {

    @Autowired
    private IGoodsService goodsService;


    @ApiOperation("分页查询商品")
    @PostMapping("/listPage")
    public Response<Page<Goods>> listPage(@RequestBody QueryPageParam qp2){
        return goodsService.listPage(qp2);
    }

    @ApiOperation("添加/编辑物品")
    @PostMapping
    public Response<Boolean> add(@RequestBody Goods goods){
        return goodsService.add(goods);
    }

    @ApiOperation("删除物品")
    @DeleteMapping("/{id}")
    public Response<Boolean> delete(@PathVariable("id") Integer id){
        return goodsService.delete(id);
    }

}
